package com.example.concurrentprogramming8016.locksupport;

import java.util.concurrent.locks.LockSupport;

/**
 * @author liyanhao
 * @Date 2023-02-08 0:24
 *  lockSupport 实现阻塞和唤醒
 */
public class LockSupportDemo {
    public static void main(String[] args) {
        Thread thread = new Thread(new ParkThread());
        thread.start();
        System.out.println("唤醒ParkThread");
        LockSupport.unpark(thread);
    }

    static class ParkThread implements Runnable {
        @Override
        public void run() {
            System.out.println("ParkThread开始执行");
            LockSupport.park();
            System.out.println("ParkThread执行完成");
        }
    }

}
